package com.kelvem.saas.workbanch.fsm;

import com.kelvem.saas.workbanch.fsm.core.FsmClassPathScanner;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.Configuration;

/**
 *
 */
@Configuration
@Slf4j
public class FsmScannerConfig implements BeanDefinitionRegistryPostProcessor {

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        FsmClassPathScanner scanner = new FsmClassPathScanner(registry);

        // 扫描 com.kelvem 包
        int cnt = scanner.scan("com.kelvem");
        log.info("scanner result.size=" + cnt);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        // 无需实现
    }

}
